<!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.0 Transitional//EN"> 
<html>
<head>
	<title>后台首页</title>
	<include file="Public:jsandcss" />
	<script type="text/javascript" src="/Public/js/uploadify/jquery.uploadify.min.js"></script>
	<link rel="Stylesheet" type="text/css" href="/Public/js/uploadify/uploadify.css" />
	<script type="text/javascript">
	$(function(){
		$('#fileUpload').uploadify({
			'swf'      : '/Public/js/uploadify/uploadify.swf',
			'formData' : {'id':$("#eventId").val()},
			'uploader' : '__URL__/fileUpload',
			'buttonText' : '选择文件',
			'onUploadSuccess' : function(file, data, response) {
				data = eval("("+data+")");
				if(response){
	            	$("<div><img width='200' src='"+data['path']+"' /><a href='"+data['path']+"' target='_blank'>预览大图</a>&nbsp;<a href='javascript:;' alt='"+data['id']+"' onclick='delImg(this)'>删除</a><br><div>").appendTo($("#imgContext"));
	            }else{
	            	alert(file.name + ' 上传失败');
	            }
	        }
		});
	});
	
	function delImg(a){
		$.post("/Admin/NewEvent/delImg/id/"+$(a).attr("alt"),function(){
			$(a).parent().remove();
		});
	}
	
	function deploy(){
		if($("#eventId").val()==""){
			alert("您还没有保存过这个活动");
			return false;
		}
		if(window.confirm("确定发布到网站，这样前台就可以看到")){
			$.post("__URL__/deploy/id/"+$("#eventId").val(),function(){
				alert("发布成功");
			});
		}
	}
	</script>
</head>

	<body>
		<include file="Public:header" />
		<form action="__URL__/saveEvent">
		<input type="submit" value="保存"/> &nbsp;&nbsp;
		<input type="button" onclick="deploy()" value="发布到前台"/>
		<table border="1" width="100%" cellpadding="0" cellspacing="0">
			<tr height="30">
				<td width="30%">标题(50字以内)：</td>
				<td><input type="text" name="title" value="{$data.title}" style="width: 200px" size="40"/></td>
			</tr>
			<tr height="30">
				<td>关键字（100字以内，英文逗号分隔）：</td>
				<td><input type="text" name="key" value="{$data.key}" style="width: 200px"/></td>
			</tr>
			<tr>
				<td>说明(300字内)：</td>
				<td>
				<textarea rows="4" name="explain" cols="50">{$data.explain}</textarea>
				</td>
			</tr>
			<input type="hidden" id="eventId" name="id" value="{$id}"/>
		</table> 
		</form>
		<if condition="$id neq ''">
			请按顺序添加图片(添加图片不用再次保存)：
			<input type="text" id="fileUpload"/>
			<div id="imgContext" style="width: 800px;height: 400px;overflow: scroll;">
				<voList name="fileList" id="vo">
					<div><img src="{$vo.imgPath}" width="200"/>
					<a href="{$vo.imgPath}" target="_blank">预览大图</a>&nbsp;
					<a href="javascript:;" alt="{$vo.id}" onclick="delImg(this)">删除</a><br>
					</div>
				</voList>
			</div>
		</if>
	</body>
</html>
